using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.ComponentModel.Design;

namespace LeisureCenter.Controls
{
    public class ScrollBar : Control
    {
        public ScrollBar()
        {
            Paint += new PaintEventHandler(ScrollBar_Paint);
            Width = 20;
            BackColor = SystemColors.Window;
            ForeColor = SystemColors.ButtonFace;
            DoubleBuffered = true;
        }

        void ScrollBar_Paint(object sender, PaintEventArgs e)
        {
            if (count == 0 || visibleCount == 0)
                return;
            e.Graphics.SmoothingMode = SmoothingMode.HighSpeed;
            Rectangle rect = ClientRectangle;
            rect.X += 4;
            rect.Width -= 4;
            rect.Y += (rect.Height * position) / count;
            rect.Height = rect.Height * (visibleCount) / count;
            rect.Height = Math.Min(rect.Height, Height - rect.Y - Padding.Bottom);
            Brush brush = new SolidBrush(ForeColor);
            Panel.FillRoundRect(e.Graphics, rect, brush);
            brush.Dispose();
        }

        private int count;

        public int Count
        {
            get { return count; }
            set
            {
                count = value;
                Invalidate();
            }
        }

        private int visibleCount;

        public int VisibleCount
        {
            get { return visibleCount; }
            set 
            {
                visibleCount = value;
                Invalidate();
            }
        }

        private int position;

        public int Position
        {
            get { return position; }
            set 
            {
                position = value;
                Invalidate();
            }
        }

    }
}
